<template>
  <div style="min-width:1366px;">
    <!-- 搜索栏区域 -->
    <el-card class="SearchCard" body-style="padding:0px">
      <el-row>
        <el-col :span="2">
          <div class="SearchTitle">条件搜索栏</div>
        </el-col>
        <el-col :span="4">
          <el-row>
            <el-col :span="10">
              <div class="SearchLable">搜索关键字</div>
            </el-col>

            <el-col :span="14">
              <div class="SearchLable">
                <el-input placeholder="请输入内容" v-model="queryInfo.srm" clearable @clear="clearEvent"></el-input>
              </div>
            </el-col>
          </el-row>
        </el-col>
        <el-col :span="2">
          <div class="SearchLable">
            <el-button size="medium" type="primary" @click="getSearchList()">搜索</el-button>
          </div>
        </el-col>
        <!-- <el-col :span="2">
          <div class="SearchLable">
            <el-button size="medium" @click="dialogVisible=true" type="primary">添加新药</el-button>
          </div>
        </el-col>-->
      </el-row>
    </el-card>
    <el-card class="TableCard" :body-style="{ padding: '0px' }">
      <div>
        <el-table
          :data="tableData"
          border
          height="550"
          :header-cell-style="{ 'text-align':'center',background: '#3F9DFD', color: '#FFF' }"
          :cell-style="{'text-align':'center'}"
          size="medium"
          stripe
          style="width: 100%;font-size:12px"
        >
          <el-table-column prop="drugCode" label="药品编码" width="100"></el-table-column>
          <el-table-column prop="name" label="操作" width="120">
            <template slot-scope="scope">
              <el-button
                type="text"
                @click="showCount(scope.row.pregnancyDrugId,scope.row.id,scope.row.drugCode,scope.row.drugName)"
              >操作</el-button>
            </template>
          </el-table-column>

          <el-table-column prop="drugName" label="药品名称"></el-table-column>

          <el-table-column label="药品类型">
            <template slot-scope="scope">
              <div v-if="scope.row.nameType==8">西药</div>
              <div v-else-if="scope.row.nameType==2">草药</div>
              <div v-else-if="scope.row.nameType==6">中成药</div>
            </template>
          </el-table-column>
          <el-table-column prop="drugSpec" label="药品规格"></el-table-column>
          <el-table-column prop="compName" label="药品生产厂家" width="220"></el-table-column>
          <el-table-column prop="approvalCode" label="批准文号"></el-table-column>
          <el-table-column prop="doseUnit" label="批准文号"></el-table-column>
        </el-table>
      </div>
      <div class="block">
        <el-pagination
          @size-change="handleSizeChange"
          @current-change="handleCurrentChange"
          :current-page="queryInfo.pagenum"
          :page-sizes="[20, 50, 100]"
          :page-size="queryInfo.pageSize"
          layout="total, sizes, prev, pager, next, jumper"
          :total="this.total"
          background
        ></el-pagination>
      </div>
    </el-card>

    <!-- 显示单期全期 -->
    <el-dialog
      :title="'全期、单期'+'—'+this.drugName"
      :visible.sync="showCountVisible"
      width="40%"
      :before-close="handleClose2"
    >
      <el-row :gutter="24" style="margin-bottom: 20px;">
        <el-col :span="12">
          <el-card shadow="hover">
            <span style="font-weight:bold">单期妊娠</span>

            <el-button
              style="float: right; padding: 3px 0;"
              @click="showRuleAll(1)"
              v-if="this.AloneDay>0"
              type="text"
            >查 看</el-button>
            <el-button
              style="float: right; padding: 3px 0;margin-right:12px;"
              @click="showAddExam(1)"
              type="text"
            >新 增</el-button>
          </el-card>
        </el-col>
        <el-col :span="12">
          <el-card shadow="hover">
            <span style="font-weight:bold">全期妊娠</span>

            <el-button
              style="float: right; padding: 3px 0"
              v-if="this.AllDay>0"
              @click="showRuleAll(2)"
              type="text"
            >查 看</el-button>
            <el-button
              style="float: right; padding: 3px 0;margin-right:12px;"
              @click="showAddExam(2)"
              type="text"
            >新 增</el-button>
          </el-card>
        </el-col>
      </el-row>
    </el-dialog>
    <!-- 新增规则 -->

    <el-dialog
      :title="((this.addRuleData.load==1)?'单期':'全期')+'--新增规则'"
      :visible.sync="AddPreRuleVisible"
      width="50%"
      :before-close="handleClose"
    >
      <div class="addRuleAdverse">
        <el-form
          :inline="true"
          :model="addRuleData"
          class="demo-form-inline addForm"
          label-width="150px"
        >
          <el-row>
            <el-col :span="12">
              <el-form-item label="警示级别">
                <el-select v-model="addRuleData.slCode" size="medium" placeholder="请选择">
                  <el-option
                    v-for="item in SlOptions"
                    :key="item.value"
                    :label="item.label"
                    :value="item.value"
                  ></el-option>
                </el-select>
              </el-form-item>
            </el-col>
            <el-col :span="12">
              <el-form-item label="给药类型">
                <el-select v-model="addRuleData.routeType" size="medium" placeholder="请选择">
                  <el-option
                    v-for="item in RouteOptions"
                    :key="item.value"
                    :label="item.label"
                    :value="item.value"
                  ></el-option>
                </el-select>
              </el-form-item>
            </el-col>
          </el-row>
          <el-row>
            <el-col :span="12">
              <el-form-item label="给药途径">
                <el-input v-model="addRuleData.routeName" size="medium">
                  <el-button slot="append" @click="showRoute(1)">选择</el-button>
                </el-input>
              </el-form-item>
            </el-col>
            <el-col :span="12">
              <el-form-item label="妊娠最低天数">
                <el-input v-model="addRuleData.pregdayslow" size="medium"></el-input>
              </el-form-item>
            </el-col>
          </el-row>
          <el-row>
            <el-col :span="12">
              <el-form-item label="妊娠最高天数">
                <el-input v-model="addRuleData.pregdayshigh" size="medium"></el-input>
              </el-form-item>
            </el-col>
          </el-row>
          <el-row>
            <el-col :span="12">
              <el-form-item label="问题详细信息描述">
                <el-input
                  v-model="addRuleData.abstractDesc"
                  type="textarea"
                  :rows="5"
                  size="medium"
                ></el-input>
              </el-form-item>
            </el-col>
            <el-col :span="12">
              <el-form-item label="警示信息">
                <el-input v-model="addRuleData.warning" type="textarea" :rows="5" size="medium"></el-input>
              </el-form-item>
            </el-col>
          </el-row>
        </el-form>
      </div>
      <span slot="footer" class="dialog-footer">
        <el-button type="primary" @click="addRule()">新 增</el-button>
        <el-button @click="AddPreRuleVisible = false">取 消</el-button>
      </span>
    </el-dialog>
    <!-- 选择给药途径ID -->
    <el-dialog
      title="选择给药途径"
      :visible.sync="RouteVisible"
      class="editDialog"
      width="30%"
      :before-close="handleClose"
    >
      <div style="width:100%;height:527px">
        <div class="addInput">
          <el-input v-model="routeData.srm" size="small" placeholder="请输入内容"></el-input>
          <el-button style="margin-right:8px" type="primary" size="small" @click="SearchDrug()">搜索</el-button>
        </div>
        <el-table
          :data="routeData.tableData"
          stripe
          border
          height="400"
          style="width: 100%;font-size: 10px"
          :header-cell-style="{'text-align':'center'}"
          :row-style="{height:'40px'}"
          :cell-style="{'text-align':'center',padding:'0px'}"
        >
          <el-table-column label width="35">
            <template slot-scope="scope">
              <el-radio :label="scope.row" v-model="routeData.radioId">&nbsp;</el-radio>
            </template>
          </el-table-column>

          <el-table-column prop="routeId" width="150" label="给药途径编码"></el-table-column>
          <el-table-column prop="routeName" label="给药途径名称"></el-table-column>
        </el-table>
        <!-- <el-pagination background layout="prev, pager, next" :total="1000"></el-pagination> -->
        <div class="dialogBlock">
          <el-pagination
            @size-change="handleSizeChange1"
            @current-change="handleCurrentChange1"
            current-page.sync="1"
            :page-size="100"
            layout="total, prev, pager, next"
            :total="routeData.total"
          ></el-pagination>
        </div>
        <span slot="footer" class="dialog-footer">
          <div class="SortFoot">
            <el-button
              style="margin-right:8px"
              type="primary"
              size="small"
              @click="SelectRoute()"
            >确定</el-button>
            <el-button style="margin-right:8px" @click="RouteVisible = false" size="small">取消</el-button>
          </div>
        </span>
      </div>
    </el-dialog>
    <!-- + (==1)?'单期':'全期' -->
    <el-dialog
      :title="this.drugName+'—' + '所有药品妊娠规则' "
      :visible.sync="PreRuleVisible"
      class="editDialog"
      width="55%"
      stripe
      :before-close="handleClose"
    >
      <div>
        <el-card style="height:530px">
          <el-table
            :data="PreRuleAloneData.PreRuleAloneTableList"
            :header-cell-style="{'text-align':'center'}"
            :cell-style="{'text-align':'center',padding:'0px'}"
            border
            stripe
            height="450"
            style="width: 100%"
          >
            <el-table-column type="index" label="序号" width="50" fixed></el-table-column>
            <el-table-column label="操作" width="100" fixed>
              <template slot-scope="scope">
                <el-button
                  v-if="PreRuleAloneData.load==1"
                  type="text"
                  style="margin-right:12px"
                  @click="showAdultRuleOne(scope.row.id)"
                >查看</el-button>
                <el-button
                  v-else
                  type="text"
                  style="margin-right:12px"
                  @click="showAdultRuleAllOne(scope.row.id)"
                >查看</el-button>
                <el-button type="text" @click="open(scope.row.id,scope.row.drugId)">删除</el-button>
              </template>
            </el-table-column>
            <el-table-column prop="drugId" label="药品" width="100"></el-table-column>

            <el-table-column label="给药类型" width="120">
              <template
                slot-scope="scope"
              >{{(scope.row.routeType==1)?"全身给药":(scope.row.routeType==2)?"局部给药":(scope.row.routeType==3)?"所有方式给药":"1"}}</template>
            </el-table-column>
            <el-table-column prop="routeIds" label="给药途径" width="130"></el-table-column>
            <el-table-column prop="pregDaysLow" label="妊娠期低值" width="100"></el-table-column>
            <el-table-column prop="pregDaysHigh" label="妊娠期高值" width="100"></el-table-column>
            <el-table-column label="警示级别" width="100">
              <!-- 警示级别 0:拦截，1：禁忌，2：不推荐，3：轻微 -->
              <template
                slot-scope="scope"
              >{{(scope.row.slCode==0)?"拦截":(scope.row.slCode==1)?"禁忌":(scope.row.slCode==2)?"不推荐":(scope.row.slCode==3)?"轻微":""}}</template>
            </el-table-column>
            <el-table-column prop="warning" label="警示信息" width="150"></el-table-column>
            <el-table-column prop="abstractDesc" label="问题详细信息描述" width="170"></el-table-column>
          </el-table>
          <el-pagination
            @size-change="handleSizeChange2"
            @current-change="handleCurrentChange2"
            :current-page="1"
            :page-sizes="[20, 30, 50]"
            :page-size="PreRuleAloneData.pageSize"
            layout="total, sizes, prev, pager, next, jumper"
            :total="PreRuleAloneData.total"
          ></el-pagination>
        </el-card>
      </div>
    </el-dialog>
    <el-dialog
      :title="((this.addRuleData.load==1)?'单期':'全期')+'—'+'妊娠规则'"
      :visible.sync="showPreRuleOneVisible"
      width="35%"
      :before-close="handleClose"
    >
      <div class="addRuleAdverse">
        <el-form
          :inline="true"
          :model="showPreRuleOneData"
          class="demo-form-inline"
          label-width="150px"
        >
          <!-- <el-form-item label="药品名称">
            <el-input v-model="showPreRuleOneData.drugName" size="medium"></el-input>
          </el-form-item>-->
          <el-form-item label="给药类型">
            <el-select v-model="showPreRuleOneData.routeType" size="medium" placeholder="请选择">
              <el-option
                v-for="item in RouteOptions"
                :key="item.value"
                :label="item.label"
                :value="item.value"
              ></el-option>
            </el-select>
          </el-form-item>
          <el-form-item label="给药途径ID">
            <el-input v-model="showPreRuleOneData.routeName" size="medium">
              <el-button slot="append" @click="showRoute(2)">选择</el-button>
            </el-input>
          </el-form-item>
          <el-form-item label="妊娠最低天数">
            <el-input v-model="showPreRuleOneData.pregDaysLow" size="medium"></el-input>
          </el-form-item>
          <el-form-item label="妊娠最高天数">
            <el-input v-model="showPreRuleOneData.pregDaysHigh" size="medium"></el-input>
          </el-form-item>
          <el-form-item label="警示级别">
            <el-select v-model="showPreRuleOneData.slCode" size="medium" placeholder="请选择">
              <el-option
                v-for="item in SlOptions"
                :key="item.value"
                :label="item.label"
                :value="item.value"
              ></el-option>
            </el-select>
          </el-form-item>
          <el-form-item label="警示信息">
            <el-input v-model="showPreRuleOneData.warning" size="medium"></el-input>
          </el-form-item>
          <el-form-item label="问题详细信息描述">
            <el-input v-model="showPreRuleOneData.abstractDesc" size="medium"></el-input>
          </el-form-item>
        </el-form>
      </div>
      <span slot="footer" class="dialog-footer">
        <el-button type="primary" @click="UpdataRule()">更 新</el-button>
        <el-button @click="showPreRuleOneVisible = false">取 消</el-button>
      </span>
    </el-dialog>
  </div>
</template>
<script>
import {
  // 获取列表
  getRuleGestationList,
  // 获取全期单期妊娠
  showCount,
  // 新增全期妊娠
  addUpdateExamDataAll,
  getRouteJson,
  // 新增单期妊娠
  addUpdateExamData,
  // 查看单期妊娠
  showRUleAddExamData,
  // 查看全期妊娠
  showRUleAddExamAllData,
  // 查看一个单期
  showExamDataDayOne,
  DeleteExamDataDayOne,
  DeleteExamDataAllDayOne,
  //查看一个全期
  showExamDataAllDayOne,
} from "@/api/rad";
export default {
  data() {
    return {
      queryInfo: {
        srm: "",
        page: 1,
        pageSize: 20,
      },
      total: 0,
      tableData: [],
      showCountVisible: false,
      SlOptions: [
        {
          value: 0,
          label: "拦截",
        },
        {
          value: 1,
          label: "禁忌",
        },
        {
          value: 2,
          label: "不推荐",
        },
        {
          value: 3,
          label: "轻微",
        },
      ],
      RouteOptions: [
        {
          value: 1,
          label: "全身给药",
        },
        {
          value: 2,
          label: "局部给药",
        },
        {
          value: 3,
          label: "所有方式给药",
        },
      ],
      // 药品id
      id: "",
      drugCode: "",
      pregnancyDrugId: 0,
      drugName: "",
      AloneDay: 0,
      AllDay: 0,

      // AloneDay: {
      //   id: ""
      // },
      // AllDay: {
      //   id: ""
      // },
      // CountData: [],
      AddPreRuleVisible: false,
      addRuleData: {
        load: 0,
        slCode: "",
        routeType: "",
        routeIds: "",
        routeName: "",
        pregdayslow: "",
        pregdayshigh: "",

        warning: "",
        abstractDesc: "",
        // classId: "",
        drugCode: "",
      },
      RouteVisible: false,
      routeData: {
        load: 0,
        srm: "",
        page: "",
        pageSize: "",
        load: 0,
        total: 0,
        tableData: [],
        radioId: [],
      },
      PreRuleVisible: false,
      PreRuleAloneData: {
        load: "",
        drugId: "",
        page: 1,
        pageSize: 20,
        total: 0,
        PreRuleAloneTableList: [],
      },
      showPreRuleOneVisible: false,
      showPreRuleOneData: {
        id: "",
        drugId: "",
        routeType: "",
        routeIds: "",
        pregDaysLow: "",
        pregDaysHigh: "",
        slCode: "",
        warning: "",
        abstractDesc: "",
      },
    };
  },
  created: function () {
    this.getRuleGestationList();
  },
  methods: {
    handleClose(done) {
      done();
    },
    handleClose2(done) {
      this.CountData = [];
      done();
    },
    handleSizeChange(newSize) {
      this.queryInfo.pageSize = newSize;
      this.getRuleGestationList();
    },

    handleCurrentChange(newPage) {
      this.queryInfo.page = newPage;
      this.getRuleGestationList();
    },
    handleSizeChange1(newSize) {
      this.routeData.pageSize = newSize;
      this.getRouteJson();
    },
    handleCurrentChange1(newPage) {
      this.routeData.page = newPage;
      this.getRouteJson();
    },
    handleSizeChange2(newSize) {
      this.PreRuleAloneData.pageSize = newSize;
      this.showRUleAddExamData();
    },
    handleCurrentChange2(newPage) {
      this.PreRuleAloneData.page = newPage;
      this.showRUleAddExamData();
    },
    async getRuleGestationList() {
      let res = await this.$rad.getRuleGestationList({
        srm: this.queryInfo.srm,
        page: this.queryInfo.page,
        pageSize: this.queryInfo.pageSize,
      });
      this.tableData = res.rows;
      this.total = res.total;
      console.log(res);
    },
    getSearchList() {
      this.getRuleGestationList();
    },
    clearEvent() {},
    // 查询单期全期新增查看
    async showCount(pregnancyDrugId, id, drugCode, drugName) {
      this.id = id;
      this.drugCode = drugCode;
      this.pregnancyDrugId = pregnancyDrugId;
      this.drugName = drugName;
      this.showCountVisible = true;
      let res = await this.$rad.showCount({
        pregnancyDrugId: this.pregnancyDrugId,
      });
      console.log(res);
      // this.CountData.push(res.data);
      this.AloneDay = res.data.g_count;
      this.AllDay = res.data.d_count;
    },

    // 单期新增处理
    showAddExam(load) {
      this.addRuleData.load = load;
      this.AddPreRuleVisible = true;
    },
    showRoute(load) {
      this.routeData.load = load;
      this.RouteVisible = true;
      this.getRouteJson();
    },
    async getRouteJson() {
      let res = await this.$rad.getRouteJson({
        srm: this.routeData.srm,
        page: this.routeData.page,
        pageSize: this.routeData.pageSize,
      });
      console.log(res);
      this.routeData.tableData = res.rows;
      this.routeData.total = res.total;
    },
    SearchDrug() {
      this.getRouteJson();
    },
    SelectRoute(load) {
      if (this.routeData.load == 1) {
        this.addRuleData.routeName = this.routeData.radioId.routeName;
        this.addRuleData.routeIds = this.routeData.radioId.routeId;
      } else if (this.routeData.load == 2) {
        this.showPreRuleOneData.routeName = this.routeData.radioId.routeName;
        this.showPreRuleOneData.routeIds = this.routeData.radioId.routeId;
      }

      this.RouteVisible = false;
    },
    async addRule() {
      if (this.addRuleData.load == 1) {
        let res = await this.$rad.addUpdateExamData({
          slCode: this.addRuleData.slCode,
          routeType: this.addRuleData.routeType,
          routeIds: this.addRuleData.routeIds,
          pregDaysLow: this.addRuleData.pregdayslow,
          pregDaysHigh: this.addRuleData.pregdayshigh,
          warning: this.addRuleData.warning,
          abstractDesc: this.addRuleData.abstractDesc,

          drugCode: this.drugCode,
        });
        console.log("新增规则参数");
        console.log(this.addRuleData);
        if (res.code == 1) {
          this.AddPreRuleVisible = false;
          this.showCountVisible = false;
          // this.RefreshCount();
          // this.showCount();
          this.getRuleGestationList();
          return this.$message({
            type: "success",
            message: res.msg,
          });
        } else {
          return this.$message({
            type: "error",
            message: res.msg,
          });
        }
      } else if (this.addRuleData.load == 2) {
        let res = await this.$rad.addUpdateExamDataAll({
          slCode: this.addRuleData.slCode,
          routeType: this.addRuleData.routeType,
          routeIds: this.addRuleData.routeIds,
          pregDaysLow: this.addRuleData.pregdayslow,
          pregDaysHigh: this.addRuleData.pregdayshigh,
          warning: this.addRuleData.warning,
          abstractDesc: this.addRuleData.abstractDesc,

          drugCode: this.drugCode,
        });
        console.log("新增规则参数");
        console.log(this.addRuleData);
        if (res.code == 1) {
          this.AddPreRuleVisible = false;
          this.showCountVisible = false;
          // this.RefreshCount();
          // this.showCount();
          this.getRuleGestationList();
          return this.$message({
            type: "success",
            message: res.msg,
          });
        } else {
          return this.$message({
            type: "error",
            message: res.msg,
          });
        }
      }
    },
    showRuleAll(load) {
      this.PreRuleVisible = true;
      this.PreRuleAloneData.load = load;
      this.showRUleAddExamData();
    },
    async showRUleAddExamData() {
      if (this.PreRuleAloneData.load == 1) {
        let res = await this.$rad.showRUleAddExamData({
          drugId: this.pregnancyDrugId,
          page: this.PreRuleAloneData.page,
          pageSize: this.PreRuleAloneData.pageSize,
        });
        console.log(res);
        this.PreRuleAloneData.PreRuleAloneTableList = res.rows;
        this.PreRuleAloneData.total = res.total;
      } else if (this.PreRuleAloneData.load == 2) {
        let res = await this.$rad.showRUleAddExamAllData({
          drugId: this.pregnancyDrugId,
          page: this.PreRuleAloneData.page,
          pageSize: this.PreRuleAloneData.pageSize,
        });
        console.log(res);
        this.PreRuleAloneData.PreRuleAloneTableList = res.rows;
        this.PreRuleAloneData.total = res.total;
      }
    },
    showAdultRuleOne(id) {
      this.showPreRuleOneData.id = id;
      this.showPreRuleOneVisible = true;
      this.showExamDataDayOne();
    },
    showAdultRuleAllOne(id) {
      this.showPreRuleOneData.id = id;
      this.showPreRuleOneVisible = true;
      this.showExamDataAllDayOne();
    },
    async showExamDataDayOne() {
      let res = await this.$rad.showExamDataDayOne({
        id: this.showPreRuleOneData.id,
        // id: "this.showPreRuleOneData.id"
      });
      console.log(res);
      (this.showPreRuleOneData.routeType = res.data.routeType),
        (this.showPreRuleOneData.routeIds = res.data.routeIds),
        (this.showPreRuleOneData.pregDaysLow = res.data.pregDaysLow),
        (this.showPreRuleOneData.pregDaysHigh = res.data.pregDaysLow),
        (this.showPreRuleOneData.slCode = res.data.slCode),
        (this.showPreRuleOneData.warning = res.data.warning),
        (this.showPreRuleOneData.abstractDesc = res.data.abstractDesc);
    },
    async showExamDataAllDayOne() {
      let res = await this.$rad.showExamDataAllDayOne({
        id: this.showPreRuleOneData.id,
        // id: "this.showPreRuleOneData.id"
      });
      console.log(res);
      (this.showPreRuleOneData.routeType = res.data.routeType),
        (this.showPreRuleOneData.routeIds = res.data.routeIds),
        (this.showPreRuleOneData.pregDaysLow = res.data.pregDaysLow),
        (this.showPreRuleOneData.pregDaysHigh = res.data.pregDaysLow),
        (this.showPreRuleOneData.slCode = res.data.slCode),
        (this.showPreRuleOneData.warning = res.data.warning),
        (this.showPreRuleOneData.abstractDesc = res.data.abstractDesc);
    },
    async UpdataRule() {
      if (this.PreRuleAloneData.load == 1) {
        let res = await this.$rad.addUpdateExamData({
          // id:
          slCode: this.showPreRuleOneData.slCode,
          routeType: this.showPreRuleOneData.routeType,
          routeIds: this.showPreRuleOneData.routeIds,
          pregdayslow: this.showPreRuleOneData.pregdayslow,
          pregdayshigh: this.showPreRuleOneData.pregdayshigh,
          warning: this.showPreRuleOneData.warning,
          abstractDesc: this.showPreRuleOneData.abstractDesc,
          // classId:
          // v_count:
          drugCode: this.drugCode,
        });
        console.log(res);
        if (res.code == 1) {
          this.showPreRuleOneVisible = false;
          this.showRUleAddExamData();
          return this.$message({
            type: "success",
            message: res.msg,
          });
        } else {
          return this.$message({
            type: "error",
            message: res.msg,
          });
        }
      } else if (this.PreRuleAloneData.load == 2) {
        let res = await this.$rad.addUpdateExamDataAll({
          // id:
          slCode: this.showPreRuleOneData.slCode,
          routeType: this.showPreRuleOneData.routeType,
          routeIds: this.showPreRuleOneData.routeIds,
          pregdayslow: this.showPreRuleOneData.pregdayslow,
          pregdayshigh: this.showPreRuleOneData.pregdayshigh,
          warning: this.showPreRuleOneData.warning,
          abstractDesc: this.showPreRuleOneData.abstractDesc,
          // classId:
          // v_count:
          drugCode: this.drugCode,
        });
        console.log(res);
        if (res.code == 1) {
          this.showPreRuleOneVisible = false;
          this.showRUleAddExamData();
          return this.$message({
            type: "success",
            message: res.msg,
          });
        } else {
          return this.$message({
            type: "error",
            message: res.msg,
          });
        }
      }
    },
    open(id, drugId) {
      this.$confirm("此操作将永久删除该规则, 是否继续?", "提示", {
        confirmButtonText: "确定",
        cancelButtonText: "取消",
        type: "warning",
      })
        .then(() => {
          if (this.PreRuleAloneData.load == 1) {
            this.DeleteExamDataDayOne(id, drugId);
          } else if (this.PreRuleAloneData.load == 2) {
            this.DeleteExamDataAllDayOne(id, drugId);
          }
        })
        .catch(() => {
          this.$message({
            type: "info",
            message: "已取消删除",
          });
        });
    },
    async DeleteExamDataDayOne(id, drugId) {
      let res = await this.$rad.DeleteExamDataDayOne({
        id: id,
        drugId: drugId,
      });
      console.log(id, drugId);
      console.log(res);
      if (res.code == 1) {
        this.showRUleAddExamData(1);
        return this.$message({
          type: "success",
          message: res.msg,
        });
      } else {
        return this.$message({
          type: "error",
          message: res.msg,
        });
      }
    },
    async DeleteExamDataAllDayOne(id, drugId) {
      let res = await this.$rad.DeleteExamDataAllDayOne({
        id: id,
        drugId: drugId,
      });
      console.log(id, drugId);
      if (res.code == 1) {
        this.showRUleAddExamData(2);
        return this.$message({
          type: "success",
          message: res.msg,
        });
      } else {
        return this.$message({
          type: "error",
          message: res.msg,
        });
      }
    },
  },
};
</script>
<style scoped>
.SearchCard {
  height: 50px;
  font-size: 12px;
}
.SearchTitle {
  height: 50px;
  display: flex;
  justify-content: center;
  align-items: center;
  border-right: 1px solid #c2c2c2;
}
.SearchLable {
  height: 50px;
  display: flex;
  justify-content: center;
  align-items: center;
}
.TableCard {
  margin-left: 3px;
  margin-top: 2px;
}
.block {
  text-align: center;
  margin-top: 12px;
  margin-bottom: 12px;
}
.editDialog >>> .el-dialog__header {
  margin-bottom: 0px;
}
.editDialog >>> .el-dialog__body {
  padding-left: 0px;
  padding-right: 0px;
}
.addInput {
  height: 45px;
  display: flex;
  align-items: center;
}
.SortFoot {
  height: 50px;
  display: flex;
  justify-content: flex-end;
  align-items: center;
}
.addInput >>> .el-input {
  width: 40%;
  margin-left: 8px;
}
.addInput >>> .el-button {
  margin-left: 8px;
}
.dialogBlock {
  margin-top: 0px;
  margin-bottom: 0px;
}
.addForm >>> .el-form-item__content {
  width: 200px;
}
</style>